﻿using System;
using EmbeddedLanguage.Attributes;
using EmbeddedLanguage.SubProcessors;

namespace EmbeddedLanguage
{
    [JSNamespaceSubstition(Namespace = ObjectEx.RootNS)]
    public static class IntEx
    {
        [StandardLibraryMapping(
            JSFunctionName = "Math.sqrt"
        )]
        public static double Sqrt(this int number)
        {
            return Math.Sqrt(number);
        }

        [SubProcessor(
            JSSubProcessorType = typeof(UpToJSProcessor)
        )]
        public static Range<T> UpTo<T>(this int Start, int End, Range<T>.RangeActionList Actions)
        {
            //return DelCache_2x1<int, int, Range>
            //    .GetFn(UpTo)(Start, End);
            return new Range<T>
            {
                Start = Start,
                End = End,
                OnNew = Actions,
            };
        }
    }
}
